package com.xiaobai.common.utils.tool;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class CheckUtil {

    public static boolean checkPhone(String phone) {
        String regex = "^((13[0-9])|(14[5,7,9])|(15([0-3]|[5-9]))|(166)|(17[0,1,3,5,6,7,8])|(18[0-9])|(19[0,1,5,6,7,8,9]))\\d{8}$";
        if (phone.length() != 11) {
            return false;
        } else {
            Pattern p = Pattern.compile(regex);
            Matcher m = p.matcher(phone);
            return m.matches();
        }
    }

    public static boolean checkAccount(String account) {
        if (Func.isNull(account)) {
            return false;
        }
        // 正则表达式，匹配6到15位的数字
        String regex = "^\\d{6,15}$";
        return Pattern.matches(regex, account);
    }

    public static boolean checkPassword(String password) {
        if (Func.isNull(password)) {
            return false;
        }
        // 正则表达式，匹配6到15位的数字
        String regex = "^\\d{6,15}$";
        return Pattern.matches(regex, password);
    }
}
